package com.zmn.plat.services.impl.product;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.common.dto.StatusDTO;
import com.zmn.plat.common.constant.ProductConsts;
import com.zmn.plat.model.entity.product.ServSubsidiaryItem;
import com.zmn.plat.model.entity.product.ServSubsidiaryItemQuery;
import com.zmn.plat.persistence.interfaces.product.ServSubsidiaryItemDAO;
import com.zmn.plat.services.interfaces.product.ServSubsidiaryItemService;

/**
 * 描述:ServSubsidiaryItemServiceImpl
 *
 * @author tanghongjun
 * @since: 2018/10/16 17:56
 */
@Service
public class ServSubsidiaryItemServiceImpl implements ServSubsidiaryItemService {

    @Resource
    private ServSubsidiaryItemDAO servSubsidiaryItemDAO;

    @Override
    public ServSubsidiaryItem findByKey(Integer itemId) {
        return servSubsidiaryItemDAO.findByKey(itemId);
    }

    @Override
    public List<ServSubsidiaryItem> findByKeys(List<Integer> itemIdList) {
        return servSubsidiaryItemDAO.findByKeys(itemIdList);
    }

    @Override
    public Integer findKeyForMax() {
        return servSubsidiaryItemDAO.findKeyForMax();
    }

    @Override
    public List<ServSubsidiaryItem> listPageByQuery(ServSubsidiaryItemQuery query) {
        return servSubsidiaryItemDAO.listPageByQuery(query);
    }

    @Override
    public List<ServSubsidiaryItem> listByQuery(ServSubsidiaryItemQuery query) {
        return servSubsidiaryItemDAO.listByQuery(query);
    }

    @Override
    public List<ServSubsidiaryItem> listByProductIdAndType(Integer productId, Integer type) {
        if (type.equals(ProductConsts.SERV_SUB_TYPE_HITCH)) {
            return servSubsidiaryItemDAO.listFaultByProductIdAndType(productId);
        } else {
            return servSubsidiaryItemDAO.listWarrantyByProductIdAndType(productId);
        }
    }

    @Override
    public List<ServSubsidiaryItem> listAll() {
        return servSubsidiaryItemDAO.listAll();
    }

    @Override
    public Integer countByQuery(ServSubsidiaryItemQuery query) {
        return servSubsidiaryItemDAO.countByQuery(query);
    }

    @Override
    public Integer updateByKey(ServSubsidiaryItem servSubsidiaryItem) {
        return servSubsidiaryItemDAO.updateByKey(servSubsidiaryItem);
    }

    @Override
    public Integer updateStatus(ServSubsidiaryItem servSubsidiaryItem) {
        return servSubsidiaryItemDAO.updateStatus(servSubsidiaryItem);
    }

    @Override
    public Integer updateStatusBatch(StatusDTO dto) {
        return servSubsidiaryItemDAO.updateStatusBatch(dto);
    }

    @Override
    public Integer insert(ServSubsidiaryItem servSubsidiaryItem) {
        return servSubsidiaryItemDAO.insert(servSubsidiaryItem);
    }

    @Override
    public Integer deleteByKey(Integer itemId) {
        return servSubsidiaryItemDAO.deleteByKey(itemId);
    }
}